package cn.com.zero.base.config;

import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * @author xiongxj
 * @version 1.0.0
 * @Description dubbo项目名称配置类，主要解决在nacos中dubbo服务订阅者列表中服务名为unknown的问题
 * @createTime 2023/2/10 9:31
 */
@Configuration
public class DubboProjectNameConfig implements EnvironmentAware {

    @Value("${spring.application.name}")
    private  String applicationName;

    @Override
    public void setEnvironment(Environment environment) {
        if(StrUtil.isBlank(System.getProperty("project.name"))){
            System.setProperty("project.name",applicationName);
        }
    }
}
